package mutsumimod.cards.stand;

import com.megacrit.cardcrawl.actions.AbstractGameAction;
import com.megacrit.cardcrawl.actions.common.DrawCardAction;
import com.megacrit.cardcrawl.actions.common.GainBlockAction;
import com.megacrit.cardcrawl.actions.common.GainEnergyAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import mutsumimod.actions.MutsumiKickAction;
import mutsumimod.actions.TrueDamageCallbackAction;
import mutsumimod.cards.BaseCard;
import mutsumimod.character.Mutsumi;
import mutsumimod.powers.StandPower;
import mutsumimod.util.CardStats;
import mutsumimod.util.tags.CustomTags;

public class MutsumiKick extends BaseCard {
    public static final String ID = makeID(MutsumiKick.class.getSimpleName());
    public static final CardStats info = new CardStats(
            Mutsumi.Meta.CARD_COLOR,
            CardType.ATTACK,
            CardRarity.UNCOMMON,
            CardTarget.ENEMY,
            1
    );

    public MutsumiKick() {
        super(ID, info);
        this.damage = this.baseDamage = 10;
        this.magicNumber = this.baseMagicNumber = 16;
        standTag=5;
    }

    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {
        stand(standTag,m);
        //this.addToBot(new MutsumiKickAction(m, new DamageInfo(p, this.damage, this.damageTypeForTurn), this.magicNumber));
    }

    @Override
    public void standUse5(AbstractPlayer p,AbstractMonster m){
        addToTop(new TrueDamageCallbackAction(m, new DamageInfo(AbstractDungeon.player
                , damage, DamageInfo.DamageType.NORMAL), AbstractGameAction.AttackEffect.SLASH_VERTICAL,
                (dmg) -> {
                    if(dmg>=magicNumber){
                        addToTop(new DrawCardAction(1));
                        addToTop(new GainEnergyAction(1));
                    }
                    //addToTop(new GainBlockAction(p,dmg));
                }
        ));
    }


    @Override
    public void upgrade() {
        if (!this.upgraded) {
            this.upgradeName();
            this.upgradeDamage(4);
            this.upgradeMagicNumber(5);
        }
    }

//    @Override
//    public void triggerOnGlowCheck() {
//        StandPower power = (StandPower) AbstractDungeon.player.getPower(StandPower.POWER_ID);
//        if (power == null || power.amount < 5) {
//            return;
//        }
//        this.glowColor = AbstractCard.BLUE_BORDER_GLOW_COLOR.cpy();
//        this.applyPowers();
//        if (this.damage >= this.magicNumber) {
//            this.glowColor = AbstractCard.GOLD_BORDER_GLOW_COLOR.cpy();
//        }
//    }

    @Override
    public AbstractCard makeCopy() {
        return new MutsumiKick();
    }
}